package com.evil.common.file.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author liyang
 */

@AllArgsConstructor
public enum FileServiceProviderEnum {
    /**
     * 文件存储服务商
     */
    LOCAL(1, "本地"),
    ALIYUN(2, "阿里云"),
    ;

    @Getter
    int id;
    @Getter
    String name;

    public static FileServiceProviderEnum getById(Integer id) {
        if (id == null) {
            return null;
        }
        FileServiceProviderEnum[] enums = values();
        for (FileServiceProviderEnum e : enums) {
            if (e.getId() == (id)) {
                return e;
            }
        }
        return null;
    }

    public static String getNameById(Integer id) {
        FileServiceProviderEnum e = getById(id);
        return e == null ? "" : e.getName();
    }
}
